package iceberg;

public final class Config {

	private static final String ICEBERG_PROJECT_CONFIG = "iceberg.project.config";
	private static final String ICEBERG_PROJECT_LOCATION = "iceberg.project.location";
	private static final String ICEBERG_RULES_LOCATION = "iceberg.rules.location";
	private static final String ICEBERG_OUTPUT_FORMAT = "iceberg.output.format";
	private static final String ICEBERG_OUTPUT_TEMPFILE = "iceberg.output.tempfile";


	private Config() {
	}

	public static String getTestProjectLocation() {
		return getAndCheckProperty(ICEBERG_PROJECT_LOCATION);
	}


	public static String getConfigDirectory() {
		return getAndCheckProperty(ICEBERG_PROJECT_CONFIG);
	}

	private static String getAndCheckProperty(String propertyName) {
		String value = System.getProperty(propertyName);
		if (value == null) {
			throw new IllegalStateException("Property '" + propertyName + "' must be set.");
		}
		return value;
	}

	public static String getRuleSetLocation() {
		return getAndCheckProperty(ICEBERG_RULES_LOCATION);
	}

	public static String getOutputFormat() {
		String value = System.getProperty(ICEBERG_OUTPUT_FORMAT);
		return value == null ? "html" : value;
	}

	public static String getTempFile() {
		return getAndCheckProperty(ICEBERG_OUTPUT_TEMPFILE);
	}
}